Reverse a string¶
Reverse a string.
Sample String :
“1234abcd”
Expected output:
dcba4321
def string_reverse(S):
RS = ''
index = len(S)
while index > 0:
RS += S[index - 1]
index -= 1
return RS
# test
print(string_reverse('1234abcd'))
Output:
dcba4321